#!/usr/bin/env python3.9
# -*- encoding: utf-8 -*-
"""
@文件        :serializers.py
@说明        : 第三方接口序列化器，主要用于验证接收参数
@时间        :2022/12/01 13:27:23
@作者        :Mars
@版本        :1.0
"""
from rest_framework import serializers


class AliyunImageUrlSerializer(serializers.Serializer):
    """阿里云图片地址参数验证"""

    image_url = serializers.URLField(write_only=True, label="图像URL地址")


class AliyunHumanStyleSerializer(AliyunImageUrlSerializer):
    """人像动漫化或素描化转换参数验证"""

    style = serializers.ChoiceField(
        default="anime",
        choices=[("anime", "人像动漫化"), ("sketch", "人像素描化")],
        error_messages={"invalid_choice": "该字段选项只能选择 anime(人像动漫化) 或 sketch(人像素描化) 默认为anime"},
    )
    algo = serializers.ChoiceField(
        default="anime",
        choices=[
            ("anime", "日漫风"),
            ("3d", "3D特效"),
            ("handdrawn", "手绘风"),
            ("sketch", "铅笔画"),
            ("artstyle", "艺术特效"),
        ],
        error_messages={
            "invalid_choice": "该字段选项只能选择 anime(日漫风)、3d(3D特效)、handdrawn(手绘风)、sketch(铅笔画) 或 artstyle(艺术特效) 默认为anime"
        },
    )




class AliyunSignatureSerializer(serializers.Serializer):
    """获取文件上传签名序列化器"""

    filename = serializers.RegexField(
        regex="^[\s\S]*\.(png|jpeg|jpg|PNG|JPEG|JPG)$",
        error_messages={"invalid": "请提供png,jpg,jpeg的图片文件"},
    )
